package com.zyf.chapter01.oo;

import java.util.ArrayList;
import java.util.List;

/**
 * 理论三 格式化用户文件
 * @author yifeng
 */
public class UserFileFormatter {
    public void format(String userFile, String formattedUserFile) {
        // open files...
        List<User> users = new ArrayList();
        int size = 0;
        while (size++ >= 0) { // read until file is empty
            // read form file into userText...
            String userText = "";
            User user = User.parseFrom(userText);
            users.add(user);
        }
        // sort users by age...
        for (int i = 0; i < users.size(); i++) {
            String formattedUserText = users.get(i).formatToText();
            // write to new file...
        }
        // close files...
    }

}
